package net.pinnoocle.playdao.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.pinnoocle.playdao.entity.*;
import net.pinnoocle.playdao.entity.analysis.FlowDataListPage;
import net.pinnoocle.playdao.entity.analysis.FlowDataListSearchParams;
import net.pinnoocle.playdao.entity.shopPc.user.TopUserListVo;
import net.pinnoocle.playdao.entity.shopPc.user.UserListPageVo;
import net.pinnoocle.playdao.entity.shopPc.user.UserListSearchParams;
import net.pinnoocle.playdao.entity.web.master.MasterGroupListVo;
import net.pinnoocle.playdao.entity.web.user.MyGroupListSearchParams;
import net.pinnoocle.playdao.entity.web.user.UserScriptListPageVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 用户表(User)表数据库访问层
 *
 * @author ye
 * @since 2021-10-25 10:21:58
 */
@Mapper
public interface UserDao extends BaseMapper<User> {

    /**
     * 店铺会员列表
     * @param page
     * @param searchParams
     * @return
     */
    Page<UserListPageVo> shopUserList(Page page, @Param("params")UserListSearchParams searchParams);

    /**
     * 获取商家小程序信息
     * @param shopWechatId
     * @return
     */
    ShopWechatSetting shopWechatSetting(@Param("shopWechatId") Integer shopWechatId);

    /**
     * 用户详情
     * @param userId
     * @return
     */
    ShopUserCombination shopUserDetail(@Param("userId") String userId);

    /**
     * 获取当前会员级别的上一个级别
     * @param shopId
     * @param playTimes
     * @return
     */
    UserLevel upOneLevel(@Param("shopId") String shopId,
                         @Param("playTimes") Integer playTimes);

    /**
     * 我玩过的本|我想玩的本
     * @param page
     * @param userId
     * @param type
     * @return
     */
    Page<UserScriptListPageVo> myScripts(Page page, @Param("userId")String userId,@Param("type")Integer type);

    /**
     * 用户排行榜
     * @param page
     * @param shopId
     * @return
     */
    Page<SimpleUserInfoVo> topUserList(Page page,@Param("shopId")String shopId);

    /**
     * 用户增加上车次数
     * @param userId
     * @return
     */
    boolean updateShopUser(@Param("userId") String userId,@Param("scriptTime") Double scriptTime,
                           @Param("payAmount") Double payAmount,@Param("memberLevelId") Integer memberLevelId);

    /**
     * 获取用户玩本次数
     * @param userId
     * @return
     */
    int getUserPlayTimes(@Param("userId") String userId);

    /**
     * 我的组局
     * @param page
     * @param params
     * @return
     */
    Page<MasterGroupListVo> myGroupList(Page page, @Param("params")MyGroupListSearchParams params);

    /**
     * 门店id
     * @param shopId
     * @param offset
     * @return
     */
    List<TopUserListVo> topFiveUserList(@Param("shopId") String shopId,@Param("offset") Integer offset);

    /**
     * 用户统计
     * @param shopId
     * @param startTime
     * @param endTime
     * @param isMember
     * @return
     */
    int userStatistics(@Param("shopId") String shopId,
                       @Param("startTime") String startTime,
                       @Param("endTime") String endTime,
                       @Param("isMember") Integer isMember);

    /**
     * 累计访客数
     * @return
     */
    boolean updateUserVisitorNum(@Param("shopId") String shopId);

    /**
     * 累计浏览量
     * @param shopId
     * @return
     */
    boolean updateUserBrowserNum(@Param("shopId") String shopId);

    /**
     * 流量分析---分页
     * @param page
     * @param params
     * @return
     */
    Page<FlowDataListPage> flowDataPage(Page page,@Param("params")FlowDataListSearchParams params);

    /**
     * 统计累计用户
     * @param shopId
     * @param shopId
     * @return
     */
    int countUserByDate(@Param("shopId") String shopId,@Param("dateTime") String dateTime);

    /**
     * 统计累计付费用户
     * @param shopId
     * @param dateTime
     * @return
     */
    int countPayUserByDate(@Param("shopId") String shopId,@Param("dateTime") String dateTime);

    /**
     * 统计新付费用户
     * @param shopId
     * @return
     */
    int countNewPayUserNum(@Param("shopId") String shopId);

    /**
     * 统计老付费用户
     * @param shopId
     * @return
     */
    int countOldPayUserNum(@Param("shopId") String shopId);
}